home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / prog / tge131.arj / TGE.H < prev    next >
C/C++ Source or Header  |  1994-03-05  |  28KB  |  549 lines

  1. /*****************************************************************************
  2. *       The Graphics Engine version 1.31                                     *
  3. *                                                                            *
  4. *       The Graphics Engine code and documentation are                       *
  5. *       Copyright (c) 1993-1994 by Matthew Hildebrand; all rights reserved.  *
  6. *                                                                            *
  7. *       Unauthorised usage or modification of any or all of The Graphics     *
  8. *       Engine is strictly prohibited.                                       *
  9. *****************************************************************************/
  10.  
  11. #if !defined(TGEdotH)
  12. #define TGEdotH
  13.  
  14.  
  15.  
  16. /* Comment out this line if you're not using output modes */
  17. #define TGE_USE_OUTPUT_MODES
  18. /* Comment out this line if you're not using virtual screens */
  19. #define TGE_USE_VIRTUAL_SCREENS
  20. /* Comment out this line if you're not using fillRegion() */
  21. #define TGE_USE_REGION_FILLS
  22. /* Comment out this line if you're not using colourCloseTo()/colourCloseToX() */
  23. #define TGE_USE_COLOUR_APPROXIMATION
  24. /* Comment out this line if you're not using ellipses or circles */
  25. #define TGE_USE_ELLIPSES
  26. /* Comment out this line if you're not using images (ie. bitmaps) */
  27. #define TGE_USE_IMAGES
  28.  
  29.  
  30.  
  31. /*
  32.  * The basic structure used to store function pointers and mode data.
  33.  */
  34.  
  35. struct GraphDrv {
  36.   /* Non-I/O functions */
  37.   int far (*_initGraphics)(void);
  38.   void far (*_deInitGraphics)(void);
  39.   void far (*_setPaletteReg)(unsigned palReg, unsigned char red, unsigned char green, unsigned char blue);
  40.   void far (*_getPaletteReg)(unsigned palReg, unsigned char far *red, unsigned char far *green, unsigned char far *blue);
  41.   void far (*_setBlockPalette)(unsigned firstReg, unsigned lastReg, void far *data);
  42.   void far (*_getBlockPalette)(unsigned firstReg, unsigned lastReg, void far *data);
  43.   unsigned far (*_colourCloseTo)(unsigned char red, unsigned char green, unsigned char blue);
  44.   unsigned far (*_colourCloseToX)(unsigned char red, unsigned char green, unsigned char blue, unsigned colourExclude);
  45.   unsigned long far (*_imageSize)(int ulx, int uly, int lrx, int lry);
  46.   unsigned long far (*_imageSizeDim)(unsigned wide, unsigned deep);
  47.   void far (*_setPage)(unsigned pageNum);    /* not implemented yet */
  48.  
  49.   /* Currently active I/O functions */
  50.   void huge (*_getImage)(int ulx, int uly, int lrx, int lry, void far *image);
  51.   void far (*_getLine)(int lineNum, int xOff, int lineLen, void far *buf);
  52.   unsigned far (*_getPixel)(int x, int y);
  53.   void huge (*_putImage)(int x, int y, void far *image);
  54.   void huge (*_putImageInv)(int x, int y, void far *image);
  55.   void far (*_putLine)(int lineNum, int xOff, int lineLen, void far *buf);
  56.   void far (*_putLineInv)(int lineNum, int xOff, int lineLen, void far *buf);
  57.   void far (*_putPixel)(int x, int y, unsigned colour);
  58.   void far (*_line)(int x1, int y1, int x2, int y2, unsigned colour);
  59.   void far (*_horizLine)(int y, int x1, int x2, unsigned colour);
  60.   void far (*_vertLine)(int x, int y1, int y2, unsigned colour);
  61.   void far (*_drawRect)(int ulx, int uly, int lrx, int lry, unsigned colour);
  62.   void far (*_filledRect)(int ulx, int uly, int lrx, int lry, unsigned colour);
  63.   void far (*_clearGraphics)(unsigned colour);
  64.   void far (*_ellipse)(int xc, int yc, int wide, int deep, unsigned colour);
  65.   void far (*_filledEllipse)(int xc, int yc, int wide, int deep, unsigned colour);
  66.   void far (*_circle)(int x, int y, int radius, unsigned colour);
  67.   void far (*_filledCircle)(int x, int y, int radius, unsigned colour);
  68.   void far (*_fillRegion)(int x, int y, unsigned colour);
  69.   void far (*_fillLine)(int y, int x1, int x2, unsigned colour);
  70.  
  71.   /* Input functions */
  72.   void huge (*_getImage_scr)(int ulx, int uly, int lrx, int lry, void far *image);
  73.   void huge (*_getImage_mem)(int ulx, int uly, int lrx, int lry, void far *image);
  74.   void far (*_getLine_scr)(int lineNum, int xOff, int lineLen, void far *buf);
  75.   void far (*_getLine_mem)(int lineNum, int xOff, int lineLen, void far *buf);
  76.   unsigned far (*_getPixel_scr)(int x, int y);
  77.   unsigned far (*_getPixel_mem)(int x, int y);
  78.  
  79.   /* Output functions */
  80.   void huge (*_putImage_scr_copy)(int x, int y, void far *image);
  81.   void huge (*_putImage_scr_and) (int x, int y, void far *image);
  82.   void huge (*_putImage_scr_not) (int x, int y, void far *image);
  83.   void huge (*_putImage_scr_or)  (int x, int y, void far *image);
  84.   void huge (*_putImage_scr_xor) (int x, int y, void far *image);
  85.   void huge (*_putImage_mem_copy)(int x, int y, void far *image);
  86.   void huge (*_putImage_mem_and) (int x, int y, void far *image);
  87.   void huge (*_putImage_mem_not) (int x, int y, void far *image);
  88.   void huge (*_putImage_mem_or)  (int x, int y, void far *image);
  89.   void huge (*_putImage_mem_xor) (int x, int y, void far *image);
  90.   void huge (*_putImageInv_scr_copy)(int x, int y, void far *image);
  91.   void huge (*_putImageInv_scr_and) (int x, int y, void far *image);
  92.   void huge (*_putImageInv_scr_not) (int x, int y, void far *image);
  93.   void huge (*_putImageInv_scr_or)  (int x, int y, void far *image);
  94.   void huge (*_putImageInv_scr_xor) (int x, int y, void far *image);
  95.   void huge (*_putImageInv_mem_copy)(int x, int y, void far *image);
  96.   void huge (*_putImageInv_mem_and) (int x, int y, void far *image);
  97.   void huge (*_putImageInv_mem_not) (int x, int y, void far *image);
  98.   void huge (*_putImageInv_mem_or)  (int x, int y, void far *image);
  99.   void huge (*_putImageInv_mem_xor) (int x, int y, void far *image);
  100.   void far (*_putLine_scr_copy)(int lineNum, int xOff, int lineLen, void far *buf);
  101.   void far (*_putLine_scr_and) (int lineNum, int xOff, int lineLen, void far *buf);
  102.   void far (*_putLine_scr_not) (int lineNum, int xOff, int lineLen, void far *buf);
  103.   void far (*_putLine_scr_or)  (int lineNum, int xOff, int lineLen, void far *buf);
  104.   void far (*_putLine_scr_xor) (int lineNum, int xOff, int lineLen, void far *buf);
  105.   void far (*_putLine_mem_copy)(int lineNum, int xOff, int lineLen, void far *buf);
  106.   void far (*_putLine_mem_and) (int lineNum, int xOff, int lineLen, void far *buf);
  107.   void far (*_putLine_mem_not) (int lineNum, int xOff, int lineLen, void far *buf);
  108.   void far (*_putLine_mem_or)  (int lineNum, int xOff, int lineLen, void far *buf);
  109.   void far (*_putLine_mem_xor) (int lineNum, int xOff, int lineLen, void far *buf);
  110.   void far (*_putLineInv_scr_copy)(int lineNum, int xOff, int lineLen, void far *buf);
  111.   void far (*_putLineInv_scr_and) (int lineNum, int xOff, int lineLen, void far *buf);
  112.   void far (*_putLineInv_scr_not) (int lineNum, int xOff, int lineLen, void far *buf);
  113.   void far (*_putLineInv_scr_or)  (int lineNum, int xOff, int lineLen, void far *buf);
  114.   void far (*_putLineInv_scr_xor) (int lineNum, int xOff, int lineLen, void far *buf);
  115.   void far (*_putLineInv_mem_copy)(int lineNum, int xOff, int lineLen, void far *buf);
  116.   void far (*_putLineInv_mem_and) (int lineNum, int xOff, int lineLen, void far *buf);
  117.   void far (*_putLineInv_mem_not) (int lineNum, int xOff, int lineLen, void far *buf);
  118.   void far (*_putLineInv_mem_or)  (int lineNum, int xOff, int lineLen, void far *buf);
  119.   void far (*_putLineInv_mem_xor) (int lineNum, int xOff, int lineLen, void far *buf);
  120.   void far (*_putPixel_scr_copy)(int x, int y, unsigned colour);
  121.   void far (*_putPixel_scr_and) (int x, int y, unsigned colour);
  122.   void far (*_putPixel_scr_not) (int x, int y, unsigned colour);
  123.   void far (*_putPixel_scr_or)  (int x, int y, unsigned colour);
  124.   void far (*_putPixel_scr_xor) (int x, int y, unsigned colour);
  125.   void far (*_putPixel_mem_copy)(int x, int y, unsigned colour);
  126.   void far (*_putPixel_mem_and) (int x, int y, unsigned colour);
  127.   void far (*_putPixel_mem_not) (int x, int y, unsigned colour);
  128.   void far (*_putPixel_mem_or)  (int x, int y, unsigned colour);
  129.   void far (*_putPixel_mem_xor) (int x, int y, unsigned colour);
  130.   void far (*_line_scr_copy)(int x1, int y1, int x2, int y2, unsigned colour);
  131.   void far (*_line_scr_and) (int x1, int y1, int x2, int y2, unsigned colour);
  132.   void far (*_line_scr_not) (int x1, int y1, int x2, int y2, unsigned colour);
  133.   void far (*_line_scr_or)  (int x1, int y1, int x2, int y2, unsigned colour);
  134.   void far (*_line_scr_xor) (int x1, int y1, int x2, int y2, unsigned colour);
  135.   void far (*_line_mem_copy)(int x1, int y1, int x2, int y2, unsigned colour);
  136.   void far (*_line_mem_and) (int x1, int y1, int x2, int y2, unsigned colour);
  137.   void far (*_line_mem_not) (int x1, int y1, int x2, int y2, unsigned colour);
  138.   void far (*_line_mem_or)  (int x1, int y1, int x2, int y2, unsigned colour);
  139.   void far (*_line_mem_xor) (int x1, int y1, int x2, int y2, unsigned colour);
  140.   void far (*_horizLine_scr_copy)(int y, int x1, int x2, unsigned colour);
  141.   void far (*_horizLine_scr_and) (int y, int x1, int x2, unsigned colour);
  142.   void far (*_horizLine_scr_not) (int y, int x1, int x2, unsigned colour);
  143.   void far (*_horizLine_scr_or)  (int y, int x1, int x2, unsigned colour);
  144.   void far (*_horizLine_scr_xor) (int y, int x1, int x2, unsigned colour);
  145.   void far (*_horizLine_mem_copy)(int y, int x1, int x2, unsigned colour);
  146.   void far (*_horizLine_mem_and) (int y, int x1, int x2, unsigned colour);
  147.   void far (*_horizLine_mem_not) (int y, int x1, int x2, unsigned colour);
  148.   void far (*_horizLine_mem_or)  (int y, int x1, int x2, unsigned colour);
  149.   void far (*_horizLine_mem_xor) (int y, int x1, int x2, unsigned colour);
  150.   void far (*_vertLine_scr_copy)(int x, int y1, int y2, unsigned colour);
  151.   void far (*_vertLine_scr_and) (int x, int y1, int y2, unsigned colour);
  152.   void far (*_vertLine_scr_not) (int x, int y1, int y2, unsigned colour);
  153.   void far (*_vertLine_scr_or)  (int x, int y1, int y2, unsigned colour);
  154.   void far (*_vertLine_scr_xor) (int x, int y1, int y2, unsigned colour);
  155.   void far (*_vertLine_mem_copy)(int x, int y1, int y2, unsigned colour);
  156.   void far (*_vertLine_mem_and) (int x, int y1, int y2, unsigned colour);
  157.   void far (*_vertLine_mem_not) (int x, int y1, int y2, unsigned colour);
  158.   void far (*_vertLine_mem_or)  (int x, int y1, int y2, unsigned colour);
  159.   void far (*_vertLine_mem_xor)(int x, int y1, int y2, unsigned colour);
  160.   void far (*_drawRect_scr_copy)(int ulx, int uly, int lrx, int lry, unsigned colour);
  161.   void far (*_drawRect_scr_and) (int ulx, int uly, int lrx, int lry, unsigned colour);
  162.   void far (*_drawRect_scr_not) (int ulx, int uly, int lrx, int lry, unsigned colour);
  163.   void far (*_drawRect_scr_or)  (int ulx, int uly, int lrx, int lry, unsigned colour);
  164.   void far (*_drawRect_scr_xor) (int ulx, int uly, int lrx, int lry, unsigned colour);
  165.   void far (*_drawRect_mem_copy)(int ulx, int uly, int lrx, int lry, unsigned colour);
  166.   void far (*_drawRect_mem_and) (int ulx, int uly, int lrx, int lry, unsigned colour);
  167.   void far (*_drawRect_mem_not) (int ulx, int uly, int lrx, int lry, unsigned colour);
  168.   void far (*_drawRect_mem_or)  (int ulx, int uly, int lrx, int lry, unsigned colour);
  169.   void far (*_drawRect_mem_xor) (int ulx, int uly, int lrx, int lry, unsigned colour);
  170.   void far (*_filledRect_scr_copy)(int ulx, int uly, int lrx, int lry, unsigned colour);
  171.   void far (*_filledRect_scr_and) (int ulx, int uly, int lrx, int lry, unsigned colour);
  172.   void far (*_filledRect_scr_not) (int ulx, int uly, int lrx, int lry, unsigned colour);
  173.   void far (*_filledRect_scr_or)  (int ulx, int uly, int lrx, int lry, unsigned colour);
  174.   void far (*_filledRect_scr_xor) (int ulx, int uly, int lrx, int lry, unsigned colour);
  175.   void far (*_filledRect_mem_copy)(int ulx, int uly, int lrx, int lry, unsigned colour);
  176.   void far (*_filledRect_mem_and) (int ulx, int uly, int lrx, int lry, unsigned colour);
  177.   void far (*_filledRect_mem_not) (int ulx, int uly, int lrx, int lry, unsigned colour);
  178.   void far (*_filledRect_mem_or)  (int ulx, int uly, int lrx, int lry, unsigned colour);
  179.   void far (*_filledRect_mem_xor) (int ulx, int uly, int lrx, int lry, unsigned colour);
  180.   void far (*_clearGraphics_scr_copy)(unsigned colour);
  181.   void far (*_clearGraphics_scr_and) (unsigned colour);
  182.   void far (*_clearGraphics_scr_not) (unsigned colour);
  183.   void far (*_clearGraphics_scr_or)  (unsigned colour);
  184.   void far (*_clearGraphics_scr_xor) (unsigned colour);
  185.   void far (*_clearGraphics_mem_copy)(unsigned colour);
  186.   void far (*_clearGraphics_mem_and) (unsigned colour);
  187.   void far (*_clearGraphics_mem_not) (unsigned colour);
  188.   void far (*_clearGraphics_mem_or)  (unsigned colour);
  189.   void far (*_clearGraphics_mem_xor) (unsigned colour);
  190.   void far (*_ellipse_scr_copy)(int xc, int yc, int wide, int deep, unsigned colour);
  191.   void far (*_ellipse_scr_and) (int xc, int yc, int wide, int deep, unsigned colour);
  192.   void far (*_ellipse_scr_not) (int xc, int yc, int wide, int deep, unsigned colour);
  193.   void far (*_ellipse_scr_or)  (int xc, int yc, int wide, int deep, unsigned colour);
  194.   void far (*_ellipse_scr_xor) (int xc, int yc, int wide, int deep, unsigned colour);
  195.   void far (*_ellipse_mem_copy)(int xc, int yc, int wide, int deep, unsigned colour);
  196.   void far (*_ellipse_mem_and) (int xc, int yc, int wide, int deep, unsigned colour);
  197.   void far (*_ellipse_mem_not) (int xc, int yc, int wide, int deep, unsigned colour);
  198.   void far (*_ellipse_mem_or)  (int xc, int yc, int wide, int deep, unsigned colour);
  199.   void far (*_ellipse_mem_xor) (int xc, int yc, int wide, int deep, unsigned colour);
  200.   void far (*_filledEllipse_scr_copy)(int xc, int yc, int wide, int deep, unsigned colour);
  201.   void far (*_filledEllipse_scr_and) (int xc, int yc, int wide, int deep, unsigned colour);
  202.   void far (*_filledEllipse_scr_not) (int xc, int yc, int wide, int deep, unsigned colour);
  203.   void far (*_filledEllipse_scr_or)  (int xc, int yc, int wide, int deep, unsigned colour);
  204.   void far (*_filledEllipse_scr_xor) (int xc, int yc, int wide, int deep, unsigned colour);
  205.   void far (*_filledEllipse_mem_copy)(int xc, int yc, int wide, int deep, unsigned colour);
  206.   void far (*_filledEllipse_mem_and) (int xc, int yc, int wide, int deep, unsigned colour);
  207.   void far (*_filledEllipse_mem_not) (int xc, int yc, int wide, int deep, unsigned colour);
  208.   void far (*_filledEllipse_mem_or)  (int xc, int yc, int wide, int deep, unsigned colour);
  209.   void far (*_filledEllipse_mem_xor) (int xc, int yc, int wide, int deep, unsigned colour);
  210.   void far (*_circle_scr_copy)(int x, int y, int radius, unsigned colour);
  211.   void far (*_circle_scr_and) (int x, int y, int radius, unsigned colour);
  212.   void far (*_circle_scr_not) (int x, int y, int radius, unsigned colour);
  213.   void far (*_circle_scr_or)  (int x, int y, int radius, unsigned colour);
  214.   void far (*_circle_scr_xor) (int x, int y, int radius, unsigned colour);
  215.   void far (*_circle_mem_copy)(int x, int y, int radius, unsigned colour);
  216.   void far (*_circle_mem_and) (int x, int y, int radius, unsigned colour);
  217.   void far (*_circle_mem_not) (int x, int y, int radius, unsigned colour);
  218.   void far (*_circle_mem_or)  (int x, int y, int radius, unsigned colour);
  219.   void far (*_circle_mem_xor) (int x, int y, int radius, unsigned colour);
  220.   void far (*_filledCircle_scr_copy)(int x, int y, int radius, unsigned colour);
  221.   void far (*_filledCircle_scr_and) (int x, int y, int radius, unsigned colour);
  222.   void far (*_filledCircle_scr_not) (int x, int y, int radius, unsigned colour);
  223.   void far (*_filledCircle_scr_or)  (int x, int y, int radius, unsigned colour);
  224.   void far (*_filledCircle_scr_xor) (int x, int y, int radius, unsigned colour);
  225.   void far (*_filledCircle_mem_copy)(int x, int y, int radius, unsigned colour);
  226.   void far (*_filledCircle_mem_and) (int x, int y, int radius, unsigned colour);
  227.   void far (*_filledCircle_mem_not) (int x, int y, int radius, unsigned colour);
  228.   void far (*_filledCircle_mem_or)  (int x, int y, int radius, unsigned colour);
  229.   void far (*_filledCircle_mem_xor) (int x, int y, int radius, unsigned colour);
  230.   void far (*_fillRegion_scr_copy)(int x, int y, unsigned colour);
  231.   void far (*_fillRegion_scr_and) (int x, int y, unsigned colour);
  232.   void far (*_fillRegion_scr_not) (int x, int y, unsigned colour);
  233.   void far (*_fillRegion_scr_or)  (int x, int y, unsigned colour);
  234.   void far (*_fillRegion_scr_xor) (int x, int y, unsigned colour);
  235.   void far (*_fillRegion_mem_copy)(int x, int y, unsigned colour);
  236.   void far (*_fillRegion_mem_and) (int x, int y, unsigned colour);
  237.   void far (*_fillRegion_mem_not) (int x, int y, unsigned colour);
  238.   void far (*_fillRegion_mem_or)  (int x, int y, unsigned colour);
  239.   void far (*_fillRegion_mem_xor) (int x, int y, unsigned colour);
  240.   void far (*_fillLine_scr_copy)(int y, int x1, int x2, unsigned colour);
  241.   void far (*_fillLine_scr_and) (int y, int x1, int x2, unsigned colour);
  242.   void far (*_fillLine_scr_not) (int y, int x1, int x2, unsigned colour);
  243.   void far (*_fillLine_scr_or)  (int y, int x1, int x2, unsigned colour);
  244.   void far (*_fillLine_scr_xor) (int y, int x1, int x2, unsigned colour);
  245.   void far (*_fillLine_mem_copy)(int y, int x1, int x2, unsigned colour);
  246.   void far (*_fillLine_mem_and) (int y, int x1, int x2, unsigned colour);
  247.   void far (*_fillLine_mem_not) (int y, int x1, int x2, unsigned colour);
  248.   void far (*_fillLine_mem_or)  (int y, int x1, int x2, unsigned colour);
  249.   void far (*_fillLine_mem_xor) (int y, int x1, int x2, unsigned colour);
  250.  
  251.   /* Driver data */
  252.   short scrnMaxX, scrnMaxY;                 /* physical screen dimensions */
  253.   unsigned short maxColour;                 /* maximum colour number */
  254.   unsigned short xRatio, yRatio;            /* screen aspect ratio */
  255.   unsigned short bitsPerPixel;              /* bits per pixel */
  256.   short inMaxX, inMaxY;                     /* input screen dimensions */
  257.   short outMaxX, outMaxY;                   /* output screen dimensions */
  258.   unsigned short inScreenWide, outScreenWide; /* needed for virtual screens */
  259.   short inViewportULX, inViewportULY;       /* input viewport coords */
  260.   short inViewportLRX, inViewportLRY;
  261.   short outViewportULX, outViewportULY;     /* output viewport coords */
  262.   short outViewportLRX, outViewportLRY;
  263.   unsigned short pagingSupported;           /* not implemented yet */
  264.   unsigned short curPage, maxPage;          /* not implemented yet */
  265.   unsigned short imageWideAdjust;           /* not implemented yet */
  266.   void far *inAddr;                         /* current input address */
  267.   void far *outAddr;                        /* current output address */
  268.   void far *scrAddr;                        /* screen address */
  269. };
  270.  
  271.  
  272.  
  273. /*
  274.  * Note that this C/C++ bit might not work properly with your compiler.  If
  275.  * you are using C++ and your linker reports that these functions are not
  276.  * found, try explicitly forcing the extern "C" syntax by removing these
  277.  * preprocessor directives.
  278.  */
  279.  
  280. #if defined(__cplusplus)
  281. extern "C" {
  282. #endif
  283.  
  284. /* Load/unload routines */
  285. int TGE_loadGraphDriver(char *filename);
  286. void TGE_unloadGraphDriver(void);
  287.  
  288. /* Virtual/real screen routines */
  289. #if defined(TGE_USE_VIRTUAL_SCREENS)
  290.   void TGE_setGraphicsInputAddr(void far *addr);
  291.   void TGE_setGraphicsOutputAddr(void far *addr);
  292.   void TGE_setGraphicsAddr(void far *addr);
  293.   void far *TGE_getGraphicsInputAddr(void);
  294.   void far *TGE_getGraphicsOutputAddr(void);
  295.   void far *TGE_makeVirtScreen(unsigned wide, unsigned deep);
  296. #endif
  297.  
  298. /* Output mode control routine */
  299. #if defined(TGE_USE_OUTPUT_MODES)
  300.   void TGE_setOutputMode(int mode);
  301. #endif
  302.  
  303. /* Viewport routines */
  304. void TGE_setInputViewport(int ulx, int uly, int lrx, int lry);
  305. void TGE_setOutputViewport(int ulx, int uly, int lrx, int lry);
  306. void TGE_setViewports(int ulx, int uly, int lrx, int lry);
  307. void TGE_getInputViewport(int far *ulx, int far *uly, int far *lrx, int far *lry);
  308. void TGE_getOutputViewport(int far *ulx, int far *uly, int far *lrx, int far *lry);
  309.  
  310. /* Clipping routines */
  311. int TGE_clipLine(int *x1, int *y1, int *x2, int *y2);
  312. int TGE_clipRect(int *ulx, int *uly, int *lrx, int *lry);
  313.  
  314. /* Scale bitmap */
  315. void TGE_scaleBitmap(void *srcImage, unsigned newWide, unsigned newDeep,
  316.     void *destImage);
  317.  
  318. /* Palette routines */
  319. int TGE_fadePalette(unsigned step, void *inPal, void *outPal, void *targetPal);
  320. void TGE_greyPalette(void *inPal, void *outPal);
  321. void TGE_rotatePalette(int howMuch, void *inPal, void *outPal);
  322.  
  323. /* RAW/PAL file routines */
  324. void far *TGE_loadRawFile(char *filename);
  325. int TGE_displayRawFile(int x, int y, char *filename);
  326. void far *TGE_loadPalFile(char *filename, void far *addr);
  327.  
  328. /* PCX file routines */
  329. void far *TGE_loadPcxFile(char *filename, void *palette);
  330. int TGE_displayPcxFile(int x, int y, char *filename);
  331. void far *TGE_loadPcxFilePal(char *filename, void far *addr);
  332.  
  333. #if defined(__cplusplus)
  334. };
  335. #endif
  336.  
  337.  
  338.  
  339. /*
  340.  * Declare the structure used by the system so that programs can access it.
  341.  */
  342.  
  343. extern struct GraphDrv far *TGEsys;
  344.  
  345.  
  346.  
  347. /*
  348.  * The function names of TGE's functions are defined here.  Since they are
  349.  * really just macros pretending to be functions, you can easily change
  350.  * their names here if you don't like the default ones.
  351.  */
  352.  
  353. #define initGraphics        (TGEsys->_initGraphics)
  354. #define deInitGraphics        (TGEsys->_deInitGraphics)
  355. #if defined(TGE_USE_IMAGES)
  356.   #define putImage              (TGEsys->_putImage)
  357.   #define putImageInv           (TGEsys->_putImageInv)
  358.   #define getImage              (TGEsys->_getImage)
  359. #endif
  360. #define putLine            (TGEsys->_putLine)
  361. #define putLineInv        (TGEsys->_putLineInv)
  362. #define getLine            (TGEsys->_getLine)
  363. #if defined(TGE_USE_IMAGES)
  364.   #define imageSize             (TGEsys->_imageSize)
  365.   #define imageSizeDim          (TGEsys->_imageSizeDim)
  366. #endif
  367. #define putPixel                (TGEsys->_putPixel)
  368. #define getPixel        (TGEsys->_getPixel)
  369. #define line            (TGEsys->_line)
  370. #define horizLine        (TGEsys->_horizLine)
  371. #define vertLine        (TGEsys->_vertLine)
  372. #define drawRect        (TGEsys->_drawRect)
  373. #define filledRect        (TGEsys->_filledRect)
  374. #define setPaletteReg        (TGEsys->_setPaletteReg)
  375. #define getPaletteReg        (TGEsys->_getPaletteReg)
  376. #define setBlockPalette        (TGEsys->_setBlockPalette)
  377. #define getBlockPalette        (TGEsys->_getBlockPalette)
  378. #define clearGraphics        (TGEsys->_clearGraphics)
  379. #if defined(TGE_USE_ELLIPSES)
  380.   #define ellipse               (TGEsys->_ellipse)
  381.   #define filledEllipse         (TGEsys->_filledEllipse)
  382.   #define circle                (TGEsys->_circle)
  383.   #define filledCircle          (TGEsys->_filledCircle)
  384. #endif
  385. #if defined(TGE_USE_REGION_FILLS)
  386.   #define fillRegion        (TGEsys->_fillRegion)
  387. #endif
  388. #if defined(TGE_USE_COLOUR_APPROXIMATION)
  389.   #define colourCloseTo        (TGEsys->_colourCloseTo)
  390.   #define colourCloseToX        (TGEsys->_colourCloseToX)
  391. #endif
  392. #define fillLine                (TGEsys->_fillLine)
  393.  
  394. #define loadGraphDriver       TGE_loadGraphDriver
  395. #define unloadGraphDriver     TGE_unloadGraphDriver
  396.  
  397. #if defined(TGE_USE_VIRTUAL_SCREENS)
  398.   #define setGraphicsOutputAddr TGE_setGraphicsOutputAddr /* set outputs */
  399.   #define setGraphicsInputAddr  TGE_setGraphicsInputAddr  /* set input   */
  400.   #define setGraphicsAddr       TGE_setGraphicsAddr       /* set I/O     */
  401.   #define makeVirtScreen        TGE_makeVirtScreen        /* make virtual screen */
  402.   #define getGraphicsOutputAddr TGE_getGraphicsOutputAddr /* set output  */
  403.   #define getGraphicsInputAddr  TGE_getGraphicsInputAddr  /* set input   */
  404. #endif
  405.  
  406. #if defined(TGE_USE_OUTPUT_MODES)
  407.   #define setGraphicsOutputMode   TGE_setOutputMode         /* output mode */
  408. #endif
  409.  
  410. #define setOutputViewport    TGE_setOutputViewport      /* viewports */
  411. #define setInputViewport           TGE_setInputViewport
  412. #define setViewports            TGE_setViewports
  413. #define setViewport        TGE_setViewports
  414. #define getOutputViewport    TGE_getOutputViewport
  415. #define getInputViewport          TGE_getInputViewport
  416. #define getViewport        TGE_getOutputViewport
  417.  
  418. #define clipLine        TGE_clipLine          /* clipping */
  419. #define clipRect                TGE_clipRect
  420. #define clipFilledRect          TGE_clipRect
  421. #define clipInputPoint          TGE_clipInputPoint
  422. #define clipOutputPoint         TGE_clipOutputPoint
  423. #define clipPoint               TGE_clipPoint
  424. #define pointOnScreen           TGE_pointOnScreen
  425.  
  426. #define scaleBitmap             TGE_scaleBitmap           /* scaling */
  427.  
  428. #define fadePalette             TGE_fadePalette           /* palette */
  429. #define greyPalette             TGE_greyPalette
  430. #define rotatePalette           TGE_rotatePalette
  431.  
  432. #define loadRawFile             TGE_loadRawFile           /* image files */
  433. #define displayRawFile          TGE_displayRawFile
  434. #define loadPalFile             TGE_loadPalFile
  435. #define loadPcxFile             TGE_loadPcxFile
  436. #define displayPcxFile          TGE_displayPcxFile
  437. #define loadPcxFilePal          TGE_loadPcxFilePal
  438.  
  439.  
  440.  
  441. /*
  442.  * These macros provide easy access to important mode information in the
  443.  * TGE system structure.
  444.  */
  445.  
  446. #define INMAXX            (TGEsys->inMaxX)
  447. #define INMAXY            (TGEsys->inMaxY)
  448. #define OUTMAXX            (TGEsys->outMaxX)
  449. #define OUTMAXY            (TGEsys->outMaxY)
  450. #define MAXCOLOUR        (TGEsys->maxColour)
  451. #define XRATIO            (TGEsys->xRatio)
  452. #define YRATIO            (TGEsys->yRatio)
  453. #define INVIEWPORTULX        (TGEsys->inViewportULX)
  454. #define INVIEWPORTULY        (TGEsys->inViewportULY)
  455. #define INVIEWPORTLRX        (TGEsys->inViewportLRX)
  456. #define INVIEWPORTLRY        (TGEsys->inViewportLRY)
  457. #define OUTVIEWPORTULX        (TGEsys->outViewportULX)
  458. #define OUTVIEWPORTULY        (TGEsys->outViewportULY)
  459. #define OUTVIEWPORTLRX        (TGEsys->outViewportLRX)
  460. #define OUTVIEWPORTLRY        (TGEsys->outViewportLRY)
  461. #define SCREENMAXX        (TGEsys->scrnMaxX)
  462. #define SCREENMAXY        (TGEsys->scrnMaxY)
  463. #define MAXX            (TGEsys->outMaxX)
  464. #define MAXY            (TGEsys->outMaxY)
  465. #define VIEWPORTULX        (TGEsys->outViewportULX)
  466. #define VIEWPORTULY        (TGEsys->outViewportULY)
  467. #define VIEWPORTLRX        (TGEsys->outViewportLRX)
  468. #define VIEWPORTLRY        (TGEsys->outViewportLRY)
  469.  
  470.  
  471.  
  472. /*
  473.  * These macros are for the various output modes.
  474.  */
  475.  
  476. #if defined(TGE_USE_OUTPUT_MODES)
  477.   #define TGE_COPY_PUT          0
  478.   #define TGE_AND_PUT           1
  479.   #define TGE_NOT_PUT           2
  480.   #define TGE_OR_PUT            3
  481.   #define TGE_XOR_PUT           4
  482. #endif
  483.  
  484.  
  485.  
  486. /*
  487.  * These macros are the return codes from loadGraphDriver().
  488.  */
  489.  
  490. #define TGE_SUCCESS     0        /* driver loaded successfully */
  491. #define TGE_OPEN_ERR    -1        /* error opening given file */
  492. #define TGE_FORMAT_ERR    -2        /* file is not a TGE driver */
  493. #define TGE_ALLOC_ERR    -3            /* error allocating memory */
  494. #define TGE_FILE_ERR    -4        /* file I/O error */
  495.  
  496.  
  497.  
  498. /*
  499.  * Point clipping routines.
  500.  */
  501.  
  502. #define TGE_pointOnScreen(x,y) \
  503.   ((x>=0) && (x<=TGEsys->scrnMaxX) && (y>=0) && (y<=TGEsys->scrnMaxY))
  504. #define TGE_clipInputPoint(x,y) \
  505.   ((x>=INVIEWPORTULX) && (x<=INVIEWPORTLRX) && \
  506.    (y>=INVIEWPORTULY) && (y<=INVIEWPORTLRY))
  507. #define TGE_clipOutputPoint(x,y) \
  508.   ((x>=OUTVIEWPORTULX) && (x<=OUTVIEWPORTLRX) && \
  509.    (y>=OUTVIEWPORTULY) && (y<=OUTVIEWPORTLRY))
  510. #define TGE_clipPoint(x,y) \
  511.   TGE_clipOutputPoint(x,y)
  512.  
  513.  
  514.  
  515. /*
  516.  * Image dimension macros.
  517.  */
  518.  
  519. #if defined(TGE_USE_IMAGES)
  520.   #define imageWidth(image)     ((unsigned*)image)[0]
  521.   #define imageHeight(image)    ((unsigned*)image)[1]
  522. #endif
  523.  
  524.  
  525.  
  526. /*
  527.  * Ease the use of TGE with different compilers by standardizing #defines.
  528.  */
  529.  
  530. #if defined(__TURBOC__)
  531.   #define ENABLE_INTERRUPTS     enable()
  532.   #define DISABLE_INTERRUPTS    disable()
  533.   #define GENERATE_INTERRUPT(i) geninterrupt(i)
  534. #else
  535.   #define ENABLE_INTERRUPTS     asm cli
  536.   #define DISABLE_INTERRUPTS    asm sti
  537.   #define GENERATE_INTERRUPT(i) asm int i
  538. #endif
  539.  
  540. #if !defined(__TURBOC__)
  541.   #define MK_FP(seg,ofs)        (((unsigned long)seg<<16) | ofs)
  542.   #define FP_SEG(fp)            ((unsigned short)(seg>>16))
  543.   #define FP_OFF(fp)            ((unsigned long)fp & 0xFFFF)
  544. #endif
  545.  
  546.  
  547.  
  548. #endif
  549.